<%@ page language="java" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<input type="text" name="numStatus" id="numStatus" hidden value="<s:property value="numStatus" />"/>
<div class="row">
    <!-- NEW WIDGET START -->
    <article class="col-sm-12 col-md-12 col-lg-12">
        <div class="jarviswidget well" id="wid-id-3"
             data-widget-colorbutton="false"
             data-widget-editbutton="false"
             data-widget-togglebutton="false"
             data-widget-deletebutton="false"
             data-widget-fullscreenbutton="false"
             data-widget-custombutton="false"
             data-widget-sortable="false">
            <!-- widget div-->
            <div>
                <div class="widget-body">
                    <a class="btn btn-default" id="btn-re-common" href="javascript:void(0)">
                        <i class="fa fa-lg fa-mail-reply-all"></i> 项目立项
                    </a>

                    <a title="编辑" key="ajax_edit"  class="btn btn-default pull-right pull-right-fix <s:property value="isEdit(proStart.id)"/>" href="javascript:void(0);">
                        <i class="fa fa-pencil-square-o"></i>编辑
                    </a>

                    <hr class="simple">

                    <form id="proStart" class="smart-form" novalidate="novalidate" action="" method="post">
                        <input type="hidden" name="keyId" id="keyId" value="<s:property value="proStart.id" />"/>
                        <input type="hidden" name="curDutyId" id="curDutyId" value="<s:property value="curDutyId" />"/>

                        <header id="title" style="display: block;">
                            项目立项表
                            <a  href="javascript:void(0);" key="btn-comment">
                                    <span class="txt-color-blueDark pull-right">
                                        <i class="fa-fw fa fa-comment-o"></i> 审批意见<span></span>
                                    </span>
                            </a>
                        </header>
                        <fieldset>
                            <div class="row">
                                <label class="label col col-2">
                                    项目名称
                                </label>
                                <section class="col col-5">
                                    <label class="input state-disabled" >
                                        <input type="text" name="name" id="name" placeholder="请输入项目名称" disabled="disabled"value="<s:property value="proStart.name"/>">
                                    </label>
                                </section>
                            </div>
                            <div class="row">
                                <label class="label col col-2">
                                    项目简称
                                </label>
                                <section class="col col-5">
                                    <label class="input state-disabled">
                                        <input type="text" name="subname" id="subname" placeholder="请输入项目简称" disabled value="<s:property value="proStart.subname"/>">
                                    </label>
                                </section>
                            </div>
                            <div class="row">
                                <label class="label col col-2">是否委托中介机构</label>
                                <section class="col col-5 ">
                                    <div class="inline-group" >
                                        <label class="radio state-disabled" >
                                            <input type="radio" name="isDelegate" value="1" <s:property value="proStart.isDelegate==1?'checked':''"/> disabled="disabled">
                                            <i></i>是
                                        </label>
                                        <label class="radio state-disabled" >
                                            <input type="radio" name="isDelegate" value="0" <s:property value="proStart.isDelegate==0?'checked':''"/>  disabled="disabled">
                                            <i></i>否
                                        </label>
                                    </div>
                                </section>
                            </div>
                            <s:if test="proStart.isDelegate == 1">
                                <div class="row">
                                    <label class="label col col-2">中介机构名称</label>
                                    <section class="col col-5">
                                        <label class="input state-disabled">
                                            <input name="agentName" id="agentName" disabled="disabled" placeholder="请输入中介机构名称" disabled="disabled"
                                                   type="text" value="<s:property value="proStart.agentName"/>">
                                        </label>
                                    </section>
                                </div>
                            </s:if>
                            <div class="row">
                                <label class="label col col-2">项目性质</label>
                                <section class="col col-5">
                                    <label class="input state-disabled">
                                        <input name="type" id="type" placeholder="请输入项目性质"
                                               disabled="disabled" type="text" value="<s:property value="proStart.type"/>">
                                    </label>
                                </section>
                            </div>
                            <div class="row">
                                <label class="label col col-2">项目大致建设内容</label>
                                <section class="col col-5">
                                    <label class="input state-disabled">
                                        <input name="content" id="content" placeholder="请输入项目大致建设内容" disabled="disabled"
                                               type="text" value="<s:property value="proStart.content"/>">
                                    </label>
                                </section>
                            </div>
                            <div class="row">
                                <label class="label col col-2">项目建设地点</label>
                                <section class="col col-5">
                                    <label class="input state-disabled">
                                        <input name="locate" id="locate" placeholder="请输入项目建设地点" disabled="disabled"
                                               type="text" value="<s:property value="proStart.locate"/>">
                                    </label>
                                </section>
                            </div>
                            <div class="row">
                                <label class="label col col-2">项目预计开始时间</label>
                                <section class="col col-2">
                                    <label class="input state-disabled">
                                        <i class="icon-append fa fa-calendar"></i>
                                        <input  class="hasDatepicker" name="start" id="start" placeholder="请选择项目预计开始时间" disabled="disabled"
                                                type="text" value="<s:date name="proStart.start" format="yyyy-MM-dd"/>">
                                    </label>
                                </section>
                            </div>
                            <div class="row">
                                <label class="label col col-2">项目预计完成时间</label>
                                <section class="col col-2">
                                    <label class="input state-disabled">
                                        <i class="icon-append fa fa-calendar"></i>
                                        <input class="hasDatepicker"  name="end" id="end" placeholder="请选择项目预计完成时间" disabled="disabled"
                                               type="text" value="<s:date name="proStart.end" format="yyyy-MM-dd"/>">
                                    </label>
                                </section>
                            </div>
                            <div class="row">
                                <label class="label col col-2">立项批复文件上传</label>
                                <section class="col col-5">
                                    <label class="input state-disabled">

                                        <input  id="filename" placeholder="" style="display: none" value="<s:property value="proStart.fileReplyId"/>">
                                    </label>
                                </section>
                            </div>

                            <div class="row">
                                <label class="label col col-2">项目批复金额</label>
                                <section class="col col-4">
                                    <label class="input state-disabled">
                                        <shiro:hasAnyRoles name="finance">
                                        <input name="replayMoney" id="replayMoney" placeholder="项目批复金额"
                                               disabled="disabled" value="<s:property value="proStart.replayMoney"></s:property>">
                                        </shiro:hasAnyRoles>
                                    </label>
                                </section>
                                <label class="label col money-unit-form">万元</label>
                            </div>

                            <div class="row">
                                <label class="label col col-2">批复日期</label>
                                <section class="col col-2">
                                    <label class="input state-disabled">
                                        <i class="icon-append fa fa-calendar"></i>
                                        <input class="hasDatepicker" name="replyDate" id="replyDate" placeholder="请输入批复日期" disabled="disabled"
                                               type="text" value="<s:date name="proStart.replyDate" format="yyyy-MM-dd"/>">
                                    </label>
                                </section>
                            </div>
                            <div class="row">
                                <label class="label col col-2">相关文号</label>
                                <section class="col col-5">
                                    <label class="input state-disabled">
                                        <input name="no" id="no" placeholder="请输入相关文号" disabled="disabled"
                                               type="text" value="<s:property value="proStart.no"/>">
                                    </label>
                                </section>
                            </div>
                            <div class="row">
                                <label class="label col col-2">备注</label>
                                <section class="col col-5">
                                    <label class="input state-disabled">
                                        <input name="mark" id="mark" placeholder="请输入备注" disabled="disabled"
                                               type="text" value="<s:property value="proStart.mark"/>">
                                    </label>
                                </section>
                            </div>
                            <div class="row">
                                <label class="label col col-2">提交人</label>
                                <section class="col col-2">
                                    <label class="input state-disabled">
                                        <input value="<s:property value="procreater.name"></s:property>" placeholder="" type="text" disabled="disabled">
                                    </label>
                                </section>
                                <label class="label col col-1">提交日期</label>
                                <section class="col col-2">
                                    <label class="input state-disabled">
                                        <input value="<s:date name="proStart.getCreateDate()" format="yyyy-MM-dd"></s:date>" placeholder="" type="text" disabled="disabled">
                                    </label>
                                </section>
                            </div>

                        </fieldset>
                    </form>
                </div>
            </div>
        </div>
    </article>
</div>

<script>
    //上传文件
    readLoad({
        objId:"filename",
        entityName:"fileReplyId",
        sourceId:"filename"
    });


    //返回视图
    $("#btn-re-common").click(function(){
        loadURL("ajax!prostart.action",$('#content'));
    });
    $("a[key=ajax_edit]").click(function(){
        loadURL("ajax-prostart!input.action?keyId="+$("input#keyId").val(),$('#content'));
    });



</script>
<script type="text/javascript">
    $(function(){
        var pdata= {
            keyId:$("#keyId").val(),
            flowName:"proStart"
        };
        multiDuty(pdata);
    });
    //左侧意见栏
    $("a[key=btn-comment]").unbind("click").bind("click",function(){
        var keyId = $("input#keyId").val();
        var actionUrl = "ajax-running!comment.action?bussinessId="+keyId;
        $(this).leftview('init',{
            title:"查看评论",
            actionUrl:actionUrl
        });
        var keyId = $("#keyId").val();
        $(this).leftview('foot',{'unid':keyId,callback:function(){
            var valueObj=$("input#numStatus").val();
            switch(valueObj){
                case "0":
                    //保存后再提交
                    $("#left_foot_btn_approve").off("click").on("click",function(){
                        form_save("proStart","ajax-prostart!commit.action?comment="+$("textarea#chat_textarea-expand").val(),null,function(){
                            $(this).leftview('leftClose');
                            $("#btn-re-common").trigger("click");
                        })
                    });
                    approveRequest("approve1");
                    break;

                case "1":
                    //第一步审批
                    $("#left_foot_btn_approve").off("click").on("click",function(){
                        form_save("proStart","ajax-prostart!approve1.action?comment="+$("textarea#chat_textarea-expand").val(),null,function(){
                            $(this).leftview('leftClose');
                            $("#btn-re-common").trigger("click");
                        })
                    });
                    approveRequest("approve1");
                    break;
                case "2":
                    //第二步审批
                    $("#left_foot_btn_approve").off("click").on("click",function(){
                        form_save("proStart","ajax-prostart!approve2.action?comment="+$("textarea#chat_textarea-expand").val(),null,function(){
                            $(this).leftview('leftClose');
                            $("#btn-re-common").trigger("click");
                        })
                    });
                    approveRequest("approve2");
                    break;
                case "3":
                    //第三步审批
                    $("#left_foot_btn_approve").off("click").on("click",function(){
                        form_save("proStart","ajax-prostart!approve3.action?comment="+$("textarea#chat_textarea-expand").val(),null,function(){
                            $(this).leftview('leftClose');
                            $("#btn-re-common").trigger("click");
                        })
                    });
                    approveRequest("approve3");
                    break;
                case "4":
                    //第四步审批
                    $("#left_foot_btn_approve").off("click").on("click",function(){
                        form_save("proStart","ajax-prostart!approve4.action?comment="+$("textarea#chat_textarea-expand").val(),null,function(){
                            $(this).leftview('leftClose');
                            $("#btn-re-common").trigger("click");
                        })
                    });
                    approveRequest("approve3");
                    break;
            }
            //退回
            $("#left_foot_btn_sendback").off("click").on("click",function(){
                var vActionUrl="ajax-prostart!reject.action";
                var data={proDefKey:"usertask1",keyId:$("input#keyId").val(),numStatus:0};
                ajax_action(vActionUrl,data,{},function(pdata){
                    _show(pdata);
                    $(this).leftview('leftClose');
                    $("#btn-re-common").trigger("click");
                });
            });
            $("#left_foot_btn_deny").off("click").on("click",function(){
                var vActionUrl="ajax-prostart!deny.action";
                var data={proDefKey:"endevent1",keyId:$("input#keyId").val(),numStatus:4};
                ajax_action(vActionUrl,data,{},function(pdata){
                    _show(pdata);
                    $(this).leftview('leftClose');
                    $("#btn-re-common").trigger("click");
                });
            });
            function approveRequest(method){
                $("#left_foot_btn_request").off("click").on("click",function(){
                    var vActionUrl="ajax-prostart!"+method+".action";
                    var data={proDefKey:"endevent1",keyId:$("input#keyId").val(),numStatus:4};
                    ajax_action(vActionUrl,data,{},function(pdata){
                        _show(pdata);
                        $(this).leftview('leftClose');
                        $("#btn-re-common").trigger("click");
                    });
                });
            }

        }});
    })

</script>
